<!doctype html>
<html lang="zh-Hans" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-middleware-sources/desktop/config-nacos">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.1">
<link rel="search" type="application/opensearchdescription+xml" title="Knife4j" href="/opensearch.xml">

<!-- Google Tag Manager -->
    <script>!function(e,t,a,n,g){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var m=t.getElementsByTagName(a)[0],r=t.createElement(a);r.async=!0,r.src="https://www.googletagmanager.com/gtm.js?id=GTM-TKBX678",m.parentNode.insertBefore(r,m)}(window,document,"script","dataLayer")</script>
    <!-- End Google Tag Manager -->
<script src="/js/custom.js"></script>
<script src="/js/baidu.js"></script>
<script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1589206801610969" async crossorigin="anonymous"></script><title data-rh="true">Nacos配置中心模式 | Knife4j</title><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://doc.xiaominfo.com/docs/middleware-sources/desktop/config-nacos"><meta data-rh="true" name="docusaurus_locale" content="zh-Hans"><meta data-rh="true" name="docsearch:language" content="zh-Hans"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Nacos配置中心模式 | Knife4j"><meta data-rh="true" name="description" content="Nacos配置中心模式在代表运行Insight组件时，所有数据全部来源于Nacos配置中心，由于Nacos提供了可操作的Web界面，因此使用上也是较方便的。"><meta data-rh="true" property="og:description" content="Nacos配置中心模式在代表运行Insight组件时，所有数据全部来源于Nacos配置中心，由于Nacos提供了可操作的Web界面，因此使用上也是较方便的。"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://doc.xiaominfo.com/docs/middleware-sources/desktop/config-nacos"><link data-rh="true" rel="alternate" href="https://doc.xiaominfo.com/docs/middleware-sources/desktop/config-nacos" hreflang="zh-Hans"><link data-rh="true" rel="alternate" href="https://doc.xiaominfo.com/docs/middleware-sources/desktop/config-nacos" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://3CRIMRK623-dsn.algolia.net" crossorigin="anonymous"><link rel="stylesheet" href="/assets/css/styles.66359a73.css">
<link rel="preload" href="/assets/js/runtime~main.e0db172c.js" as="script">
<link rel="preload" href="/assets/js/main.c059fb6e.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function e(e){document.documentElement.setAttribute("data-theme",e)}var t=function(){var e=null;try{e=localStorage.getItem("theme")}catch(e){}return e}();null!==t?e(t):window.matchMedia("(prefers-color-scheme: dark)").matches?e("dark"):window.matchMedia("(prefers-color-scheme: light)").matches?e("light"):e("dark")}()</script><div id="__docusaurus">
<div role="region"><a href="#" class="skipToContent_fXgn">跳到主要内容</a></div><nav class="navbar navbar--fixed-top navbarHideable_m1mJ"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/knife4j-light.svg" alt="" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/knife4j-dark.svg" alt="" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Knife4j</b></a><a class="navbar__item navbar__link" href="/docs/quick-start">文档</a><a aria-current="page" class="navbar__item navbar__link changelog navbar__link--active" href="/docs/middleware-sources">中间件</a><a class="navbar__item navbar__link changelog" href="/docs/oas">OAS规范</a><a class="navbar__item navbar__link changelog" href="/docs/action">实战指南</a><a class="navbar__item navbar__link changelog" href="/docs/changelog">更新日志</a><a class="navbar__item navbar__link changelog" href="/docs/faq">FAQ</a><div class="navbar__item dropdown dropdown--hoverable"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">旧版本</a><ul class="dropdown__menu"><li><a class="dropdown__link" target="_blank" href="/v2/index.html">2.0.9</a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="toggle_MW0i colorModeToggle_x44X"><button class="clean-btn toggleButton_yw5v toggleButtonDisabled_BJd7" type="button" disabled="" title="切换浅色/暗黑模式（当前为暗黑模式）" aria-label="切换浅色/暗黑模式（当前为暗黑模式）"><span><svg viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg" width="14" height="14" class="lightToggleIcon_SFTY"><g clip-path="url(#clip0_833_8168)"><path d="M6.59998 8.49999C7.98069 8.49999 9.09998 7.3807 9.09998 5.99999C9.09998 4.61928 7.98069 3.49999 6.59998 3.49999C5.21926 3.49999 4.09998 4.61928 4.09998 5.99999C4.09998 7.3807 5.21926 8.49999 6.59998 8.49999Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6.59985 0.5V1.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6.59985 10.5V11.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M2.7099 2.11L3.4199 2.82" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.77991 9.17999L10.4899 9.88999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1.09998 6H2.09998" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.0999 6H12.0999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M2.7099 9.88999L3.4199 9.17999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.77991 2.82L10.4899 2.11" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path></g><defs><clipPath id="clip0_833_8168"><rect width="12" height="12" fill="white" transform="translate(0.599976)"></rect></clipPath></defs></svg><svg viewBox="0 0 13 12" width="14" height="14" class="darkToggleIcon_ekgs"><path d="M10.7001 6.39501C10.6215 7.24611 10.3021 8.05721 9.77927 8.7334C9.25646 9.40959 8.55189 9.92291 7.748 10.2133C6.9441 10.5036 6.07414 10.5591 5.2399 10.3731C4.40565 10.187 3.64164 9.76728 3.03726 9.1629C2.43287 8.55851 2.01312 7.7945 1.8271 6.96026C1.64108 6.12602 1.6965 5.25605 1.98688 4.45216C2.27725 3.64826 2.79056 2.94369 3.46675 2.42088C4.14294 1.89808 4.95404 1.57866 5.80515 1.50001C5.30685 2.17414 5.06707 3.00473 5.12941 3.84071C5.19175 4.6767 5.55208 5.46254 6.14485 6.05531C6.73762 6.64808 7.52346 7.0084 8.35944 7.07074C9.19542 7.13308 10.026 6.8933 10.7001 6.39501Z" stroke="currentColor" fill="transparent" stroke-linecap="round" stroke-linejoin="round"></path></svg></span></button></div><a href="https://github.com/xiaoymin/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link icon" title="View on GitHub">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">搜索</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="回到顶部" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebar_njMd sidebarWithHideableNavbar_wUlq"><a tabindex="-1" class="sidebarLogo_isFc" href="/"><img src="/img/knife4j-light.svg" alt="" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/knife4j-dark.svg" alt="" class="themedImage_ToTc themedImage--dark_i4oU"><b>Knife4j</b></a><nav class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menuHtmlItem_M9Kj menu__list-item">
<div class="sidebar_donate">
    <div class="sidebar_sponsor">
        <a target="_blank" href="https://www.apifox.com/apiskills/apifox-auto-generates-api-docs/?utm_source=pay&utm_medium=knife4jg"><img src="/images/sponsor/apifox/Apifox IDEA@3x.png">
        </a>
    </div>
    <div class="sidebar_sponsor_submit">
        <a href="/docs/community/donate">成为赞助商</a>
    </div>
<div>
</div></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/middleware-sources">中间件介绍</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/middleware-sources/spring-cloud-gateway/spring-gateway-introduction">Spring Cloud Gateway网关聚合</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/middleware-sources/spring-webflux/spring-webflux-introduction">Spring Webflux集成</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/docs/middleware-sources/aggregation-introduction">Aggregation微服务聚合中间件</a><button aria-label="打开/收起侧边栏菜单「Aggregation微服务聚合中间件」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" aria-expanded="true" href="/docs/middleware-sources/desktop-introduction">Insight独立渲染组件</a><button aria-label="打开/收起侧边栏菜单「Insight独立渲染组件」" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/middleware-sources/desktop-introduction">介绍</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/middleware-sources/desktop-install">安装</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/middleware-sources/desktop/service-introduction">数据源-服务中心</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" aria-expanded="true" tabindex="0" href="/docs/middleware-sources/desktop/config-introduction">数据源-配置中心</a><button aria-label="打开/收起侧边栏菜单「数据源-配置中心」" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/middleware-sources/desktop/config-disk">Disk本地配置模式</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/middleware-sources/desktop/config-nacos">Nacos配置中心模式</a></li></ul></li></ul></li></ul></nav><button type="button" title="收起侧边栏" aria-label="收起侧边栏" class="button button--secondary button--outline collapseSidebarButton_PEFL"><svg width="20" height="20" aria-hidden="true" class="collapseSidebarButtonIcon_kv0_"><g fill="#7a7a7a"><path d="M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"></path><path d="M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"></path></g></svg></button></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_z5aJ"><div class="docItemContainer_c0TR"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="页面路径"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="主页面" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_OVgt"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/docs/middleware-sources/desktop-introduction"><span itemprop="name">Insight独立渲染组件</span></a><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/docs/middleware-sources/desktop/config-introduction"><span itemprop="name">数据源-配置中心</span></a><meta itemprop="position" content="2"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Nacos配置中心模式</span><meta itemprop="position" content="3"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">本页总览</button></div><div class="theme-doc-markdown markdown"><h1>Nacos配置中心模式</h1><p>Nacos配置中心模式在代表运行Insight组件时，所有数据全部来源于Nacos配置中心，由于Nacos提供了可操作的Web界面，因此使用上也是较方便的。
2</p><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="启动配置">启动配置<a class="hash-link" href="#启动配置" title="标题的直接链接">​</a></h2><p>来看Nacos模式下的<code>docker-compose.yml</code>文件，</p><div class="language-yml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockTitle_Ktv7">docker-compose.yml</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-yml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token comment" style="color:rgb(98, 114, 164)"># 通过docker-compose可以快速部署knife4j服务</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key atrule">version</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;2.0&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token key atrule">services</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token key atrule">knife4j</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token key atrule">container_name</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> knife4j</span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain">insight</span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain">nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token key atrule">restart</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> always</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token key atrule">image</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;xiaoymin/knife4j:v2.0&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token key atrule">network_mode</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;bridge&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token comment" style="color:rgb(98, 114, 164)"># 端口映射</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token key atrule">ports</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;10000:10000&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token comment" style="color:rgb(98, 114, 164)"># 指定配置属性模式为Nacos配置中心</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token key atrule">environment</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> knife4j.source=nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> knife4j.nacos.server=127.0.0.1</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token number">8848</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> knife4j.nacos.username=nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> knife4j.nacos.password=nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token comment" style="color:rgb(98, 114, 164)"># 使用者自行在所指定的nacos上创建 namespace 、dataid、group</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> knife4j.nacos.namespace=knife4j</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> knife4j.nacos.dataId=knife4j_data_id</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"> knife4j.nacos.group=DEFAULT_GROUP</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>属性说明：</p><table><thead><tr><th>属性</th><th>说明</th></tr></thead><tbody><tr><td>knife4j.source</td><td>代表当前容器以什么模式启动，nacos则代表当前组件选择的是基于Nacos配置中心</td></tr><tr><td>knife4j.nacos.server</td><td>Nacos服务地址，规则：<code>ip:port</code>,推荐Nacos版本&gt;=2.0</td></tr><tr><td>knife4j.nacos.username</td><td>Nacos鉴权用户名</td></tr><tr><td>knife4j.nacos.password</td><td>Nacos鉴权密码</td></tr><tr><td>knife4j.nacos.namespace</td><td>配置所属nacos上namespace名称</td></tr><tr><td>knife4j.nacos.dataId</td><td>配置dataId</td></tr><tr><td>knife4j.nacos.group</td><td>配置group名称</td></tr></tbody></table><p>Nacos模式需要注意的是，使用者需要事先在Nacos配置中心中创建一个配置文件(仅支持properties和yml类型)以作为Insight组件数据源启动运行，内容可以为空</p><p>创建的该配置所对应的namespace、dataId、group就是上面配置所对应的值。</p><p>而该配置，则也是Insight用来聚合各方OpenAPI数据的配置来源,下面介绍的四种模式的配置内容都存放在该配置中</p><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="文档配置">文档配置<a class="hash-link" href="#文档配置" title="标题的直接链接">​</a></h2><p>下面则介绍，如果在Nacos的配置中心，配置聚合不同类型的OpenAPI规范文档。</p><p>首先声明，不同于<a href="/docs/middleware-sources/desktop/config-disk">Disk本地配置中心</a>模式，以文件夹作为每一个文档的内容进行聚合</p><p>Nacos配置中心模式则是<strong>将所有文档的配置都配置在同一个配置中</strong></p><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="disk模式">Disk模式<a class="hash-link" href="#disk模式" title="标题的直接链接">​</a></h3><p>由于在<a href="/docs/middleware-sources/desktop/config-disk">Disk本地配置中心</a>模式中，我们聚合本地OpenAPI文件即可，而Nacos配置中心模式则有轻微不同，因为已经没有了磁盘文件，因此，用户可以将OpenAPI规范文件存放在Nacos配置中心中，这样就能利用Insight进行聚合了</p><p>示例配置如下：</p><div class="language-properties codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockTitle_Ktv7">Nacos{dataId=knife4j_data_id,group=DEFAULT_GROUP}</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-properties codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain"># 第一个文档，访问：http://ip:port/disk-t1/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[0].contextPath=disk-t1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[0].routes[0].name=分组1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[0].routes[0].dataId=openapi1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[0].routes[0].group=DEFAULT_GROUP</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[0].routes[0].order=1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># 第二个文档，访问：http://ip:port/disk-t2/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].contextPath=disk-t2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[0].name=分组2-1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[0].dataId=openapi2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[0].group=DEFAULT_GROUP</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[0].order=1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[1].name=分组2-2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[1].dataId=openapi3</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[1].group=DEFAULT_GROUP</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.disk[1].routes[1].order=2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># more....</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>在上面的配置中，我们分别配置了三个离线的OpenAPI规范文件，dataId分别是<code>openapi1</code>、<code>openapi2</code>、<code>openapi3</code></p><p>如下图所示：</p><p><img loading="lazy" src="/assets/images/knife4j-nacos-disk-f46e69b743e551b77a71e47374bc73e1.png" width="2638" height="1292" class="img_ev3q"></p><p>通过该模式的支持，以后OpenAPI定义内容则可以破历史的放在Nacos配置中心而快速进行渲染了。</p><p>Disk模式详细配置属性如下：</p><table><thead><tr><th>属性</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>knife4j</td><td><code>object</code></td><td>顶级目录</td></tr><tr><td>knife4j.disk<!-- -->[0]</td><td><code>array</code></td><td>disk模式文档，多个文档下标累加即可</td></tr><tr><td>knife4j.disk<!-- -->[0]<!-- -->.contextPath</td><td><code>string</code></td><td>当前文档路径，规则：<code>英文、数字、英文+数字等</code></td></tr><tr><td>knife4j.disk<!-- -->[0]<!-- -->.routes</td><td><code>array</code></td><td>disk模式聚合的文档数量，多个则下标增加即可</td></tr><tr><td>knife4j.disk<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.name</td><td><code>string</code></td><td>当前文档分组显示名称</td></tr><tr><td>knife4j.disk<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.dataId</td><td><code>string</code></td><td>存放在Nacos配置中的OpenAPI内容的dataId名称</td></tr><tr><td>knife4j.disk<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.group</td><td><code>string</code></td><td>该OpenAPI内容在Nacos配置中心中的group分组名称</td></tr><tr><td>knife4j.disk<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.debugUrl</td><td><code>string</code></td><td>当前文档在调试时的HTTP地址,例如：<code>http://192.168.1.1:9090</code></td></tr><tr><td>knife4j.disk<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.order</td><td><code>int</code></td><td>当前分组显示顺序值，排序规则为<code>asc</code></td></tr></tbody></table><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="cloud模式">Cloud模式<a class="hash-link" href="#cloud模式" title="标题的直接链接">​</a></h3><p>Cloud模式则配置比较简单，示例配置如下：</p><div class="language-properties codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockTitle_Ktv7">Nacos{dataId=knife4j_data_id,group=DEFAULT_GROUP}</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-properties codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># cloud模式第一个文档，http://ip:port/cloud1/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[0].contextPath=cloud1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[0].routes[0].name=用户</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[0].routes[0].uri=http://192.168.0.152:8999</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[0].routes[0].location=/v2/api-docs?group=2.X版本</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># cloud模式第二个文档，http://ip:port/cloud2/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[1].contextPath=cloud2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[1].routes[0].name=订单</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[1].routes[0].uri=http://192.168.0.153:8999</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.cloud[1].routes[0].location=/v2/api-docs?group=2.X版本</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>配置属性说明：</p><table><thead><tr><th>属性</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>knife4j</td><td><code>object</code></td><td>顶级目录</td></tr><tr><td>knife4j.cloud<!-- -->[0]</td><td><code>array</code></td><td>cloud模式文档，多个文档下标累加即可</td></tr><tr><td>knife4j.cloud<!-- -->[0]<!-- -->.contextPath</td><td><code>string</code></td><td>当前文档路径，规则：<code>英文、数字、英文+数字等</code></td></tr><tr><td>knife4j.cloud<!-- -->[0]<!-- -->.routes</td><td><code>array</code></td><td>cloud模式聚合的文档数量，多个则下标增加即可</td></tr><tr><td>knife4j.cloud<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.name</td><td><code>string</code></td><td>当前文档分组显示名称</td></tr><tr><td>knife4j.cloud<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.uri</td><td><code>string</code></td><td>cloud模式下获取OpenAPI信息的服务地址</td></tr><tr><td>knife4j.cloud<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.location</td><td><code>string</code></td><td>当前文档的实际OpenAPI接口地址</td></tr><tr><td>knife4j.cloud<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.debugUrl</td><td><code>string</code></td><td>当前文档在调试时的HTTP地址(如果不配置，默认走uri的地址),例如：<code>http://192.168.1.1:9090</code></td></tr><tr><td>knife4j.cloud<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.order</td><td><code>int</code></td><td>当前分组显示顺序值，排序规则为<code>asc</code></td></tr></tbody></table><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="nacos模式">Nacos模式<a class="hash-link" href="#nacos模式" title="标题的直接链接">​</a></h3><p>此Nacos模式则代表的是Nacos服务中心，通过配置聚合各个Nacos服务中心的各个服务的OpenAPI文档，用户需要避免混淆。</p><blockquote><p>1.只要是网络互通，各个项目组、中心的Nacos实例都可以配置。
2.Nacos版本必须大于等于2.0版本</p></blockquote><p>示例配置如下：</p><div class="language-properties codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockTitle_Ktv7">Nacos{dataId=knife4j_data_id,group=DEFAULT_GROUP}</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-properties codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain"># Nacos模式下的第一个文档，访问：http://ip:port/nacos_doc1/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].contextPath=nacos_doc1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># 聚合192.168.0.110服务器上的Nacos实例</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].server=192.168.0.110:8848</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].username=nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].password=nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].namespace=dev</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].routes[0].name=用户</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].routes[0].serviceName=userService</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].routes[0].groupName=DEFAULT_GROUP</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[0].routes[0].location=/v2/api-docs?group=2.X版本</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># Nacos模式下的第二个文档，访问：http://ip:port/nacos_doc2/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].contextPath=nacos_doc2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># 聚合192.168.0.112服务器上的Nacos实例</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].server=192.168.0.112:8848</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].username=nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].password=nacos</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].namespace=dev</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].routes[0].name=用户</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].routes[0].serviceName=orderService</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].routes[0].groupName=DEFAULT_GROUP</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.nacos[1].routes[0].location=/v2/api-docs?group=default</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>配置属性说明：</p><table><thead><tr><th>属性</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>knife4j</td><td><code>object</code></td><td>顶级目录</td></tr><tr><td>knife4j.nacos<!-- -->[0]</td><td><code>array</code></td><td>nacos模式文档，多个文档下标累加即可</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.contextPath</td><td><code>string</code></td><td>当前文档路径，规则：<code>英文、数字、英文+数字等</code></td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.server</td><td><code>string</code></td><td>nacos服务注册中心地址,规则：<code>ip:port</code>,不需要protocol</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.username</td><td><code>string</code></td><td>nacos服务注册中心用户名</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.password</td><td><code>string</code></td><td>nacos服务注册中心密码</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.password</td><td><code>string</code></td><td>nacos服务注册中心密码</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.namespace</td><td><code>string</code></td><td>nacos服务注册namespaceId</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.clusters</td><td><code>string</code></td><td>集群，多个以逗号分割</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes</td><td><code>array</code></td><td>nacos模式聚合的文档数量，多个则下标增加即可</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.name</td><td><code>string</code></td><td>当前文档分组显示名称</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.serviceName</td><td><code>string</code></td><td>nacos服务注册中心中的真实服务名称</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.groupName</td><td><code>string</code></td><td>nacos服务注册中心中的真实服务所处分组名称，例如：<code>DEFAULT_GROUP</code></td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.namespace</td><td><code>string</code></td><td>nacos服务注册中心中的真实服务所处namespace</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.location</td><td><code>string</code></td><td>当前文档的实际OpenAPI接口地址</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.debugUrl</td><td><code>string</code></td><td>当前文档在调试时的HTTP地址(如果不配置，默认走从nacos注册中心解析拿到的服务真实地址)</td></tr><tr><td>knife4j.nacos<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.order</td><td><code>int</code></td><td>当前分组显示顺序值，排序规则为<code>asc</code></td></tr></tbody></table><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="eureka模式">Eureka模式<a class="hash-link" href="#eureka模式" title="标题的直接链接">​</a></h3><p>Eureka模式则同Nacos模式差不多，聚合Eureka注册中心实例上的各个子服务OpenAPI文档</p><p>示例配置如下：</p><div class="language-properties codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockTitle_Ktv7">Nacos{dataId=knife4j_data_id,group=DEFAULT_GROUP}</div><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-properties codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain"># Eureka模式下的第一个文档，访问：http://ip:port/eureka1/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[0].contextPath=eureka1</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[0].serviceUrl=http://localhost:10000/eureka/</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[0].username=eureka鉴权账号</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[0].password=eureka鉴权密码</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[0].routes[0].name=用户</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[0].routes[0].serviceName=userService</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[0].routes[0].location=/v2/api-docs?group=2.X版本</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"># Eureka模式下的第二个文档，访问：http://ip:port/eureka2/doc.html</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[1].contextPath=eureka2</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[1].serviceUrl=http://192.168.0.220:10000/eureka/</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[1].username=eureka鉴权账号</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[1].password=eureka鉴权密码</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[1].routes[0].name=用户</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[1].routes[0].serviceName=userService</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">knife4j.eureka[1].routes[0].location=/v2/api-docs?group=2.X版本</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>配置属性说明：</p><table><thead><tr><th>属性</th><th>类型</th><th>说明</th></tr></thead><tbody><tr><td>knife4j</td><td><code>object</code></td><td>顶级目录</td></tr><tr><td>knife4j.eureka<!-- -->[0]</td><td><code>array</code></td><td>eureka模式文档，多个文档下标累加即可</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.contextPath</td><td><code>string</code></td><td>当前文档路径，规则：<code>英文、数字、英文+数字等</code></td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.serviceUrl</td><td><code>string</code></td><td>eureka服务注册中心地址</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.username</td><td><code>string</code></td><td>eureka服务注册中心用户名</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.password</td><td><code>string</code></td><td>eureka服务注册中心密码</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.routes</td><td><code>array</code></td><td>eureka模式聚合的文档数量，多个则下标增加即可</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.name</td><td><code>string</code></td><td>当前文档分组显示名称</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.serviceName</td><td><code>string</code></td><td>eureka服务注册中心中的真实服务名称</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.location</td><td><code>string</code></td><td>当前文档的实际OpenAPI接口地址</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.debugUrl</td><td><code>string</code></td><td>当前文档在调试时的HTTP地址(如果不配置，默认走从eureka注册中心解析拿到的服务真实地址)</td></tr><tr><td>knife4j.eureka<!-- -->[0]<!-- -->.routes<!-- -->[0]<!-- -->.order</td><td><code>int</code></td><td>当前分组显示顺序值，排序规则为<code>asc</code></td></tr></tbody></table></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"></div><div class="col lastUpdated_vwxv"><span class="theme-last-updated">最后<!-- -->由 <b>xiaoyumin</b> <!-- -->于 <b><time datetime="2023-03-21T14:11:59.000Z">2023年3月21日</time></b> <!-- -->更新</span></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="文档分页导航"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/middleware-sources/desktop/config-disk"><div class="pagination-nav__sublabel">上一页</div><div class="pagination-nav__label">Disk本地配置模式</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#启动配置" class="table-of-contents__link toc-highlight">启动配置</a></li><li><a href="#文档配置" class="table-of-contents__link toc-highlight">文档配置</a><ul><li><a href="#disk模式" class="table-of-contents__link toc-highlight">Disk模式</a></li><li><a href="#cloud模式" class="table-of-contents__link toc-highlight">Cloud模式</a></li><li><a href="#nacos模式" class="table-of-contents__link toc-highlight">Nacos模式</a></li><li><a href="#eureka模式" class="table-of-contents__link toc-highlight">Eureka模式</a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">文档指南</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/docs/quick-start">文档</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/community/simple-demo">示例</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/changelog">更新日志</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/upgrading/upgrading-to-v4">升级到v4.0</a></li></ul></div><div class="col footer__col"><div class="footer__title">社区</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://gitter.im/knife4j/knife4j" target="_blank" rel="noopener noreferrer" class="footer__link-item">Gitter<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://www.oschina.net/question/tag/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="footer__link-item">开源中国<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">关注公众号</div><ul class="footer__items clean-list"><li class="footer__item"><img src="/images/website/qrcode.jpg" width="150"></li></ul></div><div class="col footer__col"><div class="footer__title">更多</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://docusaurus.io" target="_blank" rel="noopener noreferrer" class="footer__link-item">Docusaurus<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://gitee.com/xiaoym/knife4j" target="_blank" rel="noopener noreferrer" class="footer__link-item">Gitee<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://github.com/xiaoymin/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Apache License 2.0 | Copyright © 2018-2023-八一菜刀 浙ICP备18027673号-1 </div></div></div></footer></div>
<script src="/assets/js/runtime~main.e0db172c.js"></script>
<script src="/assets/js/main.c059fb6e.js"></script>
<!-- Google Tag Manager (noscript) -->
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TKBX678" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) --></body>
</html>